package com.fanshuai.springcloud.web.response;

import com.fanshuai.springcloud.web.enums.StatusCode;
import lombok.Data;

@Data
public class CallResult<T> {
    private int code;
    private String message;
    private T data;

    public CallResult() {
        this.code = StatusCode.SUCCESS.code;
        this.message = StatusCode.SUCCESS.desc;
        this.data = null;
    }

    public CallResult(T data) {
        this.code = StatusCode.SUCCESS.code;
        this.message = StatusCode.SUCCESS.desc;
        this.data = data;
    }

    public CallResult(StatusCode statusCode) {
        this.code = statusCode.code;
        this.message = statusCode.desc;
        this.data = null;
    }

    public boolean isSuccess() {
        return code == StatusCode.SUCCESS.code;
    }
}
